package com.atguigu.spzx.manager.service.impl;

import com.atguigu.spzx.manager.mapper.BrandMapper;
import com.atguigu.spzx.manager.service.BrandService;
import com.atguigu.spzx.model.entity.product.Brand;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

// com.atguigu.spzx.manager.service.impl;
@Service
@Transactional
public class BrandServiceImpl implements BrandService {

    @Autowired
    private BrandMapper brandMapper ;



    @Override
    public PageInfo<Brand> findByPage(Integer page, Integer limit) {
        //1.分页查询三大步 设置起始参数
        PageHelper.startPage(page, limit);
        //2.数据库查询list的集合
        List<Brand> brandList = brandMapper.findByPage() ;
        //3.返回new PageInfo对象
        return new PageInfo(brandList);
    }

    @Override
    public void save(Brand brand) {
        brandMapper.save(brand) ;
    }

    @Override
    public List<Brand> findAll() {
        return brandMapper.findAll();
    }

    @Override
    public void edit(Brand brand) {
         brandMapper.edit(brand);
    }

    @Override
    public void deletByName(Integer id) {

        brandMapper.deleteByName(id);
    }

    @Override
    public List<Brand> findByCategory3Id(Long category3Id) {
        return brandMapper.findByCategory3Id(category3Id);
    }
}
